import { injectable } from 'inversify'
import { plainToClass } from 'class-transformer'
import { validate } from 'class-validator'
import { DemoDto } from './demo.dto'

/**
 * ## Demo 逻辑层
 */
@injectable()
export class DemoServices {
  constructor() { }

  public get() {
    return 'get success'
  }

  public async post(demo: DemoDto) {
    let demoDto = plainToClass(DemoDto, demo)
    const errors = await validate(demoDto)
    console.log(errors);

    return 'post success'
  }
}
